package com.chcplayer
{
import com.chcplayer.enums.CHEventName;

import flash.display.BitmapData;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.geom.Rectangle;

/**
 * author yh
 */
public class ChcPlayerAppModel extends EventDispatcher
{
	/**
	 */
	public static const DEFAULT_BG_COLOR:int = 0x9a9a9a;
	/**
	 */
	private var m_bmdGrid:BitmapData = new BitmapData(16, 16, false, 0xffFFff);
	/**
	 */
	private var m_blMainBarShow:Boolean = true;
	/**
	 */
	private var m_blUseGridBG:Boolean = false;
	/**
	 */
	private var m_blEditMode:Boolean = false;
	/**
	 * 临时背景色$模式
	 */
	private var m_blTempBgColoring:Boolean;
	private var m_nTempBgColor:int;
	/**
	 */
	private var m_nBgColor:int;
	/**
	 */
	public function ChcPlayerAppModel()
	{
		this._init();
	}
//--------------------------------------------------------------------------------------------------
// private
//--------------------------------------------------------------------------------------------------
	private function _init():void
	{
		m_nBgColor = DEFAULT_BG_COLOR;
		m_bmdGrid.fillRect(new Rectangle(0,0,8,8),0xcdcdcd);
		m_bmdGrid.fillRect(new Rectangle(8,8,8,8),0xcdcdcd);
	}
//==================================================================================================
// public
//==================================================================================================
	/**
	 */
	public function setBgColor(nC:int):void
	{
		m_nBgColor = nC;
		this.dispatchEvent(new Event(Event.CHANGE) );
	}
	/**
	 */
	public function getBgColor():int
	{
		if ( m_blTempBgColoring )
		{
			return m_nTempBgColor;
		}
		return m_nBgColor;
	}
	/**
	 * 临时背景色模式
	 */
	public function setTempBgColoring(bl:Boolean):void
	{
		m_blTempBgColoring = bl;
		this.dispatchEvent( new Event(Event.CHANGE) );
	}
	/**
	 * 临时背景色值
	 */
	public function setTempBgColor(nC:int):void
	{
		m_nTempBgColor = nC;
		this.dispatchEvent(new Event(Event.CHANGE) );
	}
	/**
	 */
	public function getUseGridBgMode():Boolean
	{
		return m_blUseGridBG;
	}
	/**
	 */
	public function setEditMode(bl:Boolean):void
	{
		m_blEditMode = m_blUseGridBG = bl;
		this.dispatchEvent(new Event(CHEventName.EDIT_MODE_CHANGE) );
		this.dispatchEvent(new Event(Event.CHANGE) );
	}
	/**
	 */
	public function getEditMode():Boolean
	{
		return m_blEditMode;
	}
	/**
	 */
	public function setFullScreen(bl:Boolean):void
	{
		m_blMainBarShow = !bl;
	}
	/**
	 */
	public function getMainBarIsShow():Boolean
	{
		return m_blMainBarShow;
	}
	/**
	 */
	public function getDefaultBgColor():int
	{
		return DEFAULT_BG_COLOR;
	}
	/**
	 */
	public function getGridBmd():BitmapData
	{
		return m_bmdGrid;
	}
	/**
	 */
}
}